<template>
  <div class="button">
    <div
      :class="$route.path == item.url ? 'active' : ''"
      v-for="(item, index) in list"
      :key="index"
      @click="todu(item)"
    >
      <span>{{ item.icon }}</span>
      <span>{{ item.name }}</span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [
        { name: "首页", url: "/Home", icon: "1" ,id: 3621},
        { name: "分类", url: "/List", icon: "2", id: 3624 },
        { name: "购物车", url: "/Shopcar", icon: "3",id: 3625 },
        { name: "我的", url: "/My", icon: "4 " ,id: 3628},
      ],
    };
  },
  methods: {
    todu(item) { 
      this.$router.push({ path: item.url, query: { id: item.id} });
    },
  },
};
</script>

<style lang="scss" scoped>
.button {
  width: 100vw;
  height: 60px;
  border-top: 1px solid #ccc;
  background-color: white;
  position: fixed;
  left: 0;
  bottom: 0;
  display: flex;
  justify-content: space-around;
  div {
    flex: 1;
    border: 1px solid red;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }
  .active {
    background-color: blue;
    color: red;
  }
}
</style>